import { PetUtil } from "./PetUtil";
import { SPetInfo } from "../../../../../Message/Game/SPetInfo";
type int = number;
//class PetAttrCalcUtil
    
    export  class PetAttrCalcUtil
    {
        

        public static getBaseAttrMutiValue(arg1: int, arg2: int, arg3: int): int
        {
            var loc1=0;
            var loc2=0;
            var loc3=PetUtil.getGrowthTitle(arg2);
            var loc4=PetUtil.getGrowthTitle(arg1);
            if (loc3) 
            {
                loc1 = loc3.addNum;
            }
            if (loc4) 
            {
                loc2 = loc4.addNum;
            }
            return Math.floor((PetAttrCalcUtil.getGrowthCoefficient(arg2) - PetAttrCalcUtil.getGrowthCoefficient(arg1)) * 0.16 * (arg3 - 1)) + (arg2 - arg1) * 5 + (loc1 - loc2);
        }

        public static getGrowthCoefficient(arg1: int): number
        {
            return (Math.pow(1.1, arg1) - 1) * 3.381176 + arg1 * 0.5;
        }

        public static getSpiritCoefficient(arg1: int): number
        {
            var loc1=0;
            var loc2=PetUtil.getSpiritTitle(arg1);
            if (loc2) 
            {
                loc1 = loc2.addNum;
            }
            return (Math.pow(1.15, arg1) - 1) * 10.05071 + arg1 * 1 + loc1;
        }

        public static getPhysicalAttackMuti(arg1: int, arg2: number, arg3: int, arg4: number, arg5: int, arg6: number, arg7: number): number
        {
            if (arg2 == 0 && arg4 == 0) 
            {
                return 0;
            }
            return ((arg1 * arg2 + arg3 * arg4) * (arg5 / 1000 + 0.3) + arg5 / 10) * arg6 / 100 * (1 + arg7);
        }

        public static getPhysicalDefenseMuti(arg1: int, arg2: number, arg3: int, arg4: number, arg5: int, arg6: number, arg7: number): number
        {
            return (arg1 * arg2 + arg3 * arg4) * (arg5 / 1000 + 0.3) * arg6 / 100 * (1 + arg7);
        }

        public static getMagicAttackMuti(arg1: int, arg2: number, arg3: int, arg4: number, arg5: int, arg6: number, arg7: number): number
        {
            if (arg2 == 0 && arg4 == 0) 
            {
                return 0;
            }
            return ((arg1 * arg2 + arg3 * arg4) * (arg5 / 1000 + 0.3) + arg5 / 10) * arg6 / 100 * (1 + arg7);
        }

        public static getMagicDefenseMuti(arg1: int, arg2: number, arg3: int, arg4: number, arg5: int, arg6: number, arg7: number): number
        {
            return (arg1 * arg2 + arg3 * arg4) * (arg5 / 1000 + 0.3) * arg6 / 100 * (1 + arg7);
        }

        public static getCritMuti(arg1: int, arg2: number, arg3: int, arg4: int, arg5: int, arg6: number): number
        {
            if (arg2 == 0) 
            {
                return 0;
            }
            return (arg1 * arg2 * (arg3 / 1000 + 0.3) + (arg4 + 10 * (arg5 - 1))) * arg6 / 100;
        }

        public static getHitOrJoukMuti(arg1: int, arg2: int, arg3: number): number
        {
            return (arg1 + 10 * (arg2 - 1)) * arg3 / 100;
        }

        public static getJoukMuti(arg1: int, arg2: number, arg3: int, arg4: int, arg5: int, arg6: number): number
        {
            if (arg2 == 0) 
            {
                return 0;
            }
            return (arg1 * arg2 * (arg3 / 1000 + 0.3) + (arg4 + 10 * (arg5 - 1))) * arg6 / 100;
        }

        public static getPhysicalAttackMutiBySpirit(arg1: SPetInfo, arg2: int, arg3: int): int
        {
            var loc1=0;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=NaN;
            var loc7=0;
            var loc8=NaN;
            var loc9=0;
            var loc10=NaN;
            var loc11=NaN;
            var loc12=NaN;
            if (arg1) 
            {
                loc2 = PetUtil.getTItemPet(arg1);
                loc3 = PetUtil.getPetTCareer(arg1);
                loc5 = (loc4 = arg1.baseFightAttribute).power;
                loc6 = loc3.powerPhysicalAttack / 1000;
                loc7 = loc4.agile;
                loc8 = loc3.agilePhysicalAttack / 1000;
                loc9 = arg1.talent;
                loc10 = loc4.physicalAttackPercentage / 100;
                loc11 = PetAttrCalcUtil.getSpiritCoefficient(arg3);
                loc12 = PetAttrCalcUtil.getSpiritCoefficient(arg2);
                loc1 = PetAttrCalcUtil.getPhysicalAttackMuti(loc5, loc6, loc7, loc8, loc9, loc11, loc10) - PetAttrCalcUtil.getPhysicalAttackMuti(loc5, loc6, loc7, loc8, loc9, loc12, loc10);
            }
            return Math.floor(loc1);
        }

        public static getPhysicalDefenseMutiBySpirit(arg1: SPetInfo, arg2: int, arg3: int): int
        {
            var loc1=0;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=NaN;
            var loc7=0;
            var loc8=NaN;
            var loc9=0;
            var loc10=NaN;
            var loc11=NaN;
            var loc12=NaN;
            if (arg1) 
            {
                loc2 = PetUtil.getTItemPet(arg1);
                loc3 = PetUtil.getPetTCareer(arg1);
                loc5 = (loc4 = arg1.baseFightAttribute).power;
                loc6 = loc3.powerPhysicalDefense / 1000;
                loc7 = loc4.habitus;
                loc8 = loc3.habitusPhysicalDefense / 1000;
                loc9 = arg1.talent;
                loc10 = loc4.physicalAttackPercentage / 100;
                loc11 = PetAttrCalcUtil.getSpiritCoefficient(arg3);
                loc12 = PetAttrCalcUtil.getSpiritCoefficient(arg2);
                loc1 = PetAttrCalcUtil.getPhysicalDefenseMuti(loc5, loc6, loc7, loc8, loc9, loc11, loc10) - PetAttrCalcUtil.getPhysicalDefenseMuti(loc5, loc6, loc7, loc8, loc9, loc12, loc10);
            }
            return Math.floor(loc1);
        }

        public static getMagicAttackMutiBySpirit(arg1: SPetInfo, arg2: int, arg3: int): int
        {
            var loc1=0;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=NaN;
            var loc7=0;
            var loc8=NaN;
            var loc9=0;
            var loc10=NaN;
            var loc11=NaN;
            var loc12=NaN;
            if (arg1) 
            {
                loc2 = PetUtil.getTItemPet(arg1);
                loc3 = PetUtil.getPetTCareer(arg1);
                loc5 = (loc4 = arg1.baseFightAttribute).brains;
                loc6 = loc3.brainsMagicAttack / 1000;
                loc7 = loc4.spiritual;
                loc8 = loc3.spiritualMagicAttack / 1000;
                loc9 = arg1.talent;
                loc10 = loc4.magicAttackPercentage / 100;
                loc11 = PetAttrCalcUtil.getSpiritCoefficient(arg3);
                loc12 = PetAttrCalcUtil.getSpiritCoefficient(arg2);
                loc1 = PetAttrCalcUtil.getMagicAttackMuti(loc5, loc6, loc7, loc8, loc9, loc11, loc10) - PetAttrCalcUtil.getMagicAttackMuti(loc5, loc6, loc7, loc8, loc9, loc12, loc10);
            }
            return Math.floor(loc1);
        }

        public static getMagicDefenseMutiBySpirit(arg1: SPetInfo, arg2: int, arg3: int): int
        {
            var loc1=0;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=NaN;
            var loc7=0;
            var loc8=NaN;
            var loc9=0;
            var loc10=NaN;
            var loc11=NaN;
            var loc12=NaN;
            if (arg1) 
            {
                loc2 = PetUtil.getTItemPet(arg1);
                loc3 = PetUtil.getPetTCareer(arg1);
                loc5 = (loc4 = arg1.baseFightAttribute).spiritual;
                loc6 = loc3.spiritualMagicDefense / 1000;
                loc7 = loc4.habitus;
                loc8 = loc3.habitusMagicDefense / 1000;
                loc9 = arg1.talent;
                loc10 = loc4.magicDefensePercentage / 100;
                loc11 = PetAttrCalcUtil.getSpiritCoefficient(arg3);
                loc12 = PetAttrCalcUtil.getSpiritCoefficient(arg2);
                loc1 = PetAttrCalcUtil.getMagicDefenseMuti(loc5, loc6, loc7, loc8, loc9, loc11, loc10) - PetAttrCalcUtil.getMagicDefenseMuti(loc7, loc8, loc5, loc6, loc9, loc12, loc10);
            }
            return Math.floor(loc1);
        }

        public static getHitMutiBySpirit(arg1: SPetInfo, arg2: int, arg3: int): int
        {
            var loc1=0;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=NaN;
            var loc7=NaN;
            var loc8=0;
            if (arg1) 
            {
                loc2 = PetUtil.getTItemPet(arg1);
                loc3 = PetUtil.getPetTCareer(arg1);
                loc4 = arg1.baseFightAttribute;
                if (loc2) 
                {
                    loc8 = loc2.initHit;
                }
                loc5 = arg1.level;
                loc6 = PetAttrCalcUtil.getSpiritCoefficient(arg3);
                loc7 = PetAttrCalcUtil.getSpiritCoefficient(arg2);
                loc1 = PetAttrCalcUtil.getHitOrJoukMuti(loc8, loc5, loc6) - PetAttrCalcUtil.getHitOrJoukMuti(loc8, loc5, loc7);
            }
            return Math.floor(loc1);
        }

        public static getJoukMutiBySpirit(arg1: SPetInfo, arg2: int, arg3: int): int
        {
            var loc1=0;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=NaN;
            var loc7=0;
            var loc8=0;
            var loc9=0;
            var loc10=NaN;
            var loc11=NaN;
            if (arg1) 
            {
                loc2 = PetUtil.getTItemPet(arg1);
                loc3 = PetUtil.getPetTCareer(arg1);
                loc5 = (loc4 = arg1.baseFightAttribute).agile;
                loc6 = (loc3.brainsJouk + loc3.agileJouk) / 1000;
                loc7 = arg1.talent;
                loc8 = loc2.initJouk;
                loc9 = arg1.level;
                loc10 = PetAttrCalcUtil.getSpiritCoefficient(arg3);
                loc11 = PetAttrCalcUtil.getSpiritCoefficient(arg2);
                loc1 = PetAttrCalcUtil.getJoukMuti(loc5, loc6, loc7, loc8, loc9, loc10) - PetAttrCalcUtil.getJoukMuti(loc5, loc6, loc7, loc8, loc9, loc11);
            }
            return Math.floor(loc1);
        }

        public static getPysicalCritMutiBySpirit(arg1: SPetInfo, arg2: int, arg3: int): int
        {
            var loc1=0;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=NaN;
            var loc7=0;
            var loc8=0;
            var loc9=0;
            var loc10=NaN;
            var loc11=NaN;
            if (arg1) 
            {
                loc2 = PetUtil.getTItemPet(arg1);
                loc3 = PetUtil.getPetTCareer(arg1);
                loc5 = (loc4 = arg1.baseFightAttribute).agile;
                loc6 = loc3.agilePhysicalCrit / 1000;
                loc7 = arg1.talent;
                loc8 = loc2.initCrit;
                loc9 = arg1.level;
                loc10 = PetAttrCalcUtil.getSpiritCoefficient(arg3);
                loc11 = PetAttrCalcUtil.getSpiritCoefficient(arg2);
                loc1 = PetAttrCalcUtil.getCritMuti(loc5, loc6, loc7, loc8, loc9, loc10) - PetAttrCalcUtil.getCritMuti(loc5, loc6, loc7, loc8, loc9, loc11);
            }
            return Math.floor(loc1);
        }

        public static getMagicCritMutiBySpirit(arg1: SPetInfo, arg2: int, arg3: int): int
        {
            var loc1=0;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=NaN;
            var loc7=0;
            var loc8=0;
            var loc9=0;
            var loc10=NaN;
            var loc11=NaN;
            if (arg1) 
            {
                loc2 = PetUtil.getTItemPet(arg1);
                loc3 = PetUtil.getPetTCareer(arg1);
                loc5 = (loc4 = arg1.baseFightAttribute).brains;
                loc6 = loc3.brainsMagicCrit / 1000;
                loc7 = arg1.talent;
                loc8 = loc2.initCrit;
                loc9 = arg1.level;
                loc10 = PetAttrCalcUtil.getSpiritCoefficient(arg3);
                loc11 = PetAttrCalcUtil.getSpiritCoefficient(arg2);
                loc1 = PetAttrCalcUtil.getCritMuti(loc5, loc6, loc7, loc8, loc9, loc10) - PetAttrCalcUtil.getCritMuti(loc5, loc6, loc7, loc8, loc9, loc11);
            }
            return Math.floor(loc1);
        }

        public static getCritMutiBySpirit(arg1: SPetInfo, arg2: int, arg3: int): int
        {
            var loc1=0;
            if (arg1) 
            {
                loc1 = PetAttrCalcUtil.getPysicalCritMutiBySpirit(arg1, arg2, arg3) + PetAttrCalcUtil.getMagicCritMutiBySpirit(arg1, arg2, arg3);
            }
            return Math.floor(loc1);
        }
    }
